﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Physis.Client.Models.Insurer {

    public class InsuranceTypeModel : Configuration.ConfigurationItemModel {
                
        #region Private Properties

        private Core.Insurer.InsuranceType insuranceType = null;

        #endregion


        #region Public Properties

        public override Int64 ConfigurationItemId { set { InsuranceTypeId = value; } }

        public override Core.CoreConfigurationObject ConfigurationItem { get { return insuranceType; } }


        public Int64 InsuranceTypeId {

            set {

                insuranceType = Application.Core.Insurer.InsuranceType (value);

                if (insuranceType == null) {

                    insuranceType = new Core.Insurer.InsuranceType (Application);

                }

            }

        }

        public Core.Insurer.InsuranceType InsuranceType { get { return insuranceType; } set { insuranceType = value; } }

        #endregion 


        #region Constructors

        public InsuranceTypeModel (Int64 forInsuranceTypeId) {

            InsuranceTypeId = forInsuranceTypeId;

            return;

        }

        public InsuranceTypeModel (System.Collections.Specialized.NameValueCollection form) {

            UpdateValues (form);

            return;

        }

        #endregion 


        #region Public Methods

        public override void UpdateValues (System.Collections.Specialized.NameValueCollection form) {

            base.UpdateValues (form);

            
            // BASE RELOADS THE ORIGINAL OBJECT TYPE

            InsuranceType.Code = Data.Readers.FormReader.StringFromForm (form, "InsuranceType.Code");

            return;

        }

        #endregion 

    }

}